package com.module.login.utils

import com.module.app.bean.UserBean
import com.module.base.ext.request
import com.module.base.utils.CommonUtils
import com.module.login.R
import com.module.login.model.LoginCodeViewModel
import com.module.login.model.LoginPhoneViewModel
import com.module.third.bean.push.IPushType
import com.module.third.bean.push.PushData
import com.module.third.learcloud.lcSendMessageInBackground


/**
 * 登录推送
 */
fun LoginPhoneViewModel.loginPush(pushId: String) {
    request({
        val pushData: PushData<com.module.app.bean.UserBean> = PushData<com.module.app.bean.UserBean>(IPushType.IPush.login, null)
        lcSendMessageInBackground(pushId, pushData)
    }, {
        if (it != null) {
            check(it) {
                CommonUtils.getString(R.string.error_unknow)
            }
        }
        //发送成功
    }, {
        //发送失败
    })
}

/**
 * 登录推送
 */
fun LoginCodeViewModel.loginPush(pushId: String) {
    request({
        val pushData: PushData<com.module.app.bean.UserBean> = PushData<com.module.app.bean.UserBean>(IPushType.IPush.login, null)
        lcSendMessageInBackground(pushId, pushData)
    }, {
        if (it != null) {
            check(it) {
                CommonUtils.getString(R.string.error_unknow)
            }
        }
        //发送成功
    }, {
        //发送失败
    })
}